home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Development Tools & Languages / Macintosh Common Lisp Related / interfaces / PInterface Translator / PInterfaces / MIDI.p < prev    next >
Encoding:
Text File  |  1993-09-16  |  9.8 KB  |  265 lines  |  [TEXT/MPS ]

  1. {
  2. Created: Tuesday, January 8, 1991 at 10:53 AM
  3.     MIDI.p
  4.     Pascal Interface to the Macintosh Libraries
  5.  
  6.             Copyright © 1988-1990, Apple Computer, Inc.
  7.             All Rights Reserved
  8. }
  9.  
  10.  
  11. {$IFC UNDEFINED UsingIncludes}
  12. {$SETC UsingIncludes := 0}
  13. {$ENDC}
  14.  
  15. {$IFC NOT UsingIncludes}
  16.     UNIT MIDI;
  17.     INTERFACE
  18. {$ENDC}
  19.  
  20. {$IFC UNDEFINED UsingMIDI}
  21. {$SETC UsingMIDI := 1}
  22.  
  23. {$I+}
  24. {$SETC MIDIIncludes := UsingIncludes}
  25. {$SETC UsingIncludes := 1}
  26. {$IFC UNDEFINED UsingTypes}
  27. {$I $$Shell(PInterfaces)Types.p}
  28. {$ENDC}
  29. {$SETC UsingIncludes := MIDIIncludes}
  30.  
  31. CONST
  32. midiToolNum = 4;                {tool number of MIDI Manager for SndDispVersion call}
  33. midiMaxNameLen = 31;            {maximum number of characters in port and client names}
  34.  
  35. { Time formats }
  36. midiFormatMSec = 0;             {milliseconds}
  37. midiFormatBeats = 1;            {beats}
  38. midiFormat24fpsBit = 2;         {24 frames/sec.}
  39. midiFormat25fpsBit = 3;         {25 frames/sec.}
  40. midiFormat30fpsDBit = 4;        {30 frames/sec. drop-frame}
  41. midiFormat30fpsBit = 5;         {30 frames/sec.}
  42. midiFormat24fpsQF = 6;          {24 frames/sec. longInt format }
  43. midiFormat25fpsQF = 7;          {25 frames/sec. longInt format }
  44. midiFormat30fpsDQF = 8;         {30 frames/sec. drop-frame longInt format }
  45. midiFormat30fpsQF = 9;          {30 frames/sec. longInt format }
  46. midiInternalSync = 0;           {internal sync}
  47. midiExternalSync = 1;           {external sync}
  48.  
  49. { Port types}
  50. midiPortTypeTime = 0;           {time port}
  51. midiPortTypeInput = 1;          {input port}
  52. midiPortTypeOutput = 2;         {output port}
  53. midiPortTypeTimeInv = 3;        {invisible time port}
  54.  
  55. { OffsetTimes  }
  56. midiGetEverything = $7FFFFFFF;  {get all packets, regardless of time stamps}
  57. midiGetNothing = $80000000;     {get no packets, regardless of time stamps}
  58. midiGetCurrent = $00000000;     {get current packets only}
  59.  
  60. {    MIDI data and messages are passed in MIDIPacket records (see below).
  61.     The first byte of every MIDIPacket contains a set of flags
  62.    
  63.     bits 0-1    00 = new MIDIPacket, not continued
  64.                      01 = begining of continued MIDIPacket
  65.                      10 = end of continued MIDIPacket
  66.                     11 = continuation
  67.     bits 2-3     reserved
  68.   
  69.     bits 4-6      000 = packet contains MIDI data
  70.    
  71.                      001 = packet contains MIDI Manager message
  72.    
  73.     bit 7              0 = MIDIPacket has valid stamp
  74.                         1 = stamp with current clock }
  75. midiContMask = $03;
  76. midiNoCont = $00;
  77. midiStartCont = $01;
  78. midiMidCont = $03;
  79. midiEndCont = $02;
  80. midiTypeMask = $70;
  81. midiMsgType = $00;
  82. midiMgrType = $10;
  83. midiTimeStampMask = $80;
  84. midiTimeStampCurrent = $80;
  85. midiTimeStampValid = $00;
  86.  
  87. {    MIDI Manager MIDIPacket command words (the first word in the data field
  88.     for midiMgrType messages) }
  89. midiOverflowErr = $0001;
  90. midiSCCErr = $0002;
  91. midiPacketErr = $0003;
  92. midiMaxErr = $00FF;             {all command words less than this value  are error indicators}
  93.  
  94. { Valid results to be returned by readHooks }
  95. midiKeepPacket = 0;
  96. midiMorePacket = 1;
  97. midiNoMorePacket = 2;
  98.  
  99. { Errors: }
  100. midiNoClientErr = -250;         {no client with that ID found}
  101. midiNoPortErr = -251;           {no port with that ID found}
  102. midiTooManyPortsErr = -252;     {too many ports already installed in the system}
  103. midiTooManyConsErr = -253;      {too many connections made}
  104. midiVConnectErr = -254;         {pending virtual connection created}
  105. midiVConnectMade = -255;        {pending virtual connection resolved}
  106. midiVConnectRmvd = -256;        {pending virtual connection removed}
  107. midiNoConErr = -257;            {no connection exists between specified ports}
  108. midiWriteErr = -258;            {MIDIWritePacket couldn't write to all connected ports}
  109. midiNameLenErr = -259;          {name supplied is longer than 31 characters}
  110. midiDupIDErr = -260;            {duplicate client ID}
  111. midiInvalidCmdErr = -261;       {command not supported for port type}
  112.  
  113. {     Driver calls: }
  114. midiOpenDriver = 1;
  115. midiCloseDriver = 2;
  116.  
  117. TYPE
  118. MIDIPacketPtr = ^MIDIPacket;
  119. MIDIPacket = PACKED RECORD
  120.     flags: Byte;
  121.     len: Byte;
  122.     tStamp: LONGINT;
  123.     data: PACKED ARRAY [0..248] OF Byte;
  124.     END;
  125.  
  126. MIDIClkInfo = RECORD
  127.     sync: INTEGER;              {synchronization external/internal}
  128.     curTime: LONGINT;           {current value of port's clock}
  129.     format: INTEGER;            {time code format}
  130.     END;
  131.  
  132. MIDIIDRec = RECORD
  133.     clientID: OSType;
  134.     portID: OSType;
  135.     END;
  136.  
  137. MIDIPortInfoPtr = ^MIDIPortInfo;
  138. MIDIPortInfoHdl = ^MIDIPortInfoPtr;
  139. MIDIPortInfo = RECORD
  140.     portType: INTEGER;          {type of port}
  141.     timeBase: MIDIIDRec;        {MIDIIDRec for time base}
  142.     numConnects: INTEGER;       {number of connections}
  143.     cList: ARRAY [1..100] OF MIDIIDRec;
  144.     END;
  145.  
  146. MIDIPortParamsPtr = ^MIDIPortParams;
  147. MIDIPortParams = RECORD
  148.     portID: OSType;             {ID of port, unique within client}
  149.     portType: INTEGER;          {Type of port - input, output, time, etc.}
  150.     timeBase: INTEGER;          {refnum of time base, 0 if none}
  151.     offsetTime: LONGINT;        {offset for current time stamps}
  152.     readHook: Ptr;              {routine to call when input data is valid}
  153.     refCon: LONGINT;            {refcon for port (for client use)}
  154.     initClock: MIDIClkInfo;     {initial settings for a time base}
  155.     name: Str255;               {name of the port, This is a real live string, not a ptr.}
  156.     END;
  157.  
  158. MIDIIDListPtr = ^MIDIIDList;
  159. MIDIIDListHdl = ^MIDIIDListPtr;
  160. MIDIIDList = RECORD
  161.     numIDs: INTEGER;
  162.     list: ARRAY [1..100] OF OSType;
  163.     END;
  164.  
  165.  
  166. {
  167.      Prototype Declarations for readHook and timeProc
  168.     
  169.      FUNCTION myReadHook(myPacket: MIDIPacketPtr; myRefCon: LONGINT) : INTEGER;
  170.      PROCEDURE myTimeProc(curTime: LONGINT; myRefCon: LONGINT);
  171. }
  172.  
  173. FUNCTION SndDispVersion(toolnum: INTEGER): LONGINT;
  174. FUNCTION MIDISignIn(clientID: OSType;refCon: LONGINT;icon: Handle;name: Str255): OSErr;
  175.     INLINE $203C,$0004,midiToolNum,$A800;
  176. PROCEDURE MIDISignOut(clientID: OSType);
  177.     INLINE $203C,$0008,midiToolNum,$A800;
  178. FUNCTION MIDIGetClients: MIDIIDListHdl;
  179.     INLINE $203C,$000C,midiToolNum,$A800;
  180. PROCEDURE MIDIGetClientName(clientID: OSType;VAR name: Str255);
  181.     INLINE $203C,$0010,midiToolNum,$A800;
  182. PROCEDURE MIDISetClientName(clientID: OSType;name: Str255);
  183.     INLINE $203C,$0014,midiToolNum,$A800;
  184. FUNCTION MIDIGetPorts(clientID: OSType): MIDIIDListHdl;
  185.     INLINE $203C,$0018,midiToolNum,$A800;
  186. FUNCTION MIDIAddPort(clientID: OSType;BufSize: INTEGER;VAR refnum: INTEGER;
  187.     init: MIDIPortParamsPtr): OSErr;
  188.     INLINE $203C,$001C,midiToolNum,$A800;
  189. FUNCTION MIDIGetPortInfo(clientID: OSType;portID: OSType): MIDIPortInfoHdl;
  190.     INLINE $203C,$0020,midiToolNum,$A800;
  191. FUNCTION MIDIConnectData(srcClID: OSType;srcPortID: OSType;dstClID: OSType;
  192.     dstPortID: OSType): OSErr;
  193.     INLINE $203C,$0024,midiToolNum,$A800;
  194. FUNCTION MIDIUnConnectData(srcClID: OSType;srcPortID: OSType;dstClID: OSType;
  195.     dstPortID: OSType): OSErr;
  196.     INLINE $203C,$0028,midiToolNum,$A800;
  197. FUNCTION MIDIConnectTime(srcClID: OSType;srcPortID: OSType;dstClID: OSType;
  198.     dstPortID: OSType): OSErr;
  199.     INLINE $203C,$002C,midiToolNum,$A800;
  200. FUNCTION MIDIUnConnectTime(srcClID: OSType;srcPortID: OSType;dstClID: OSType;
  201.     dstPortID: OSType): OSErr;
  202.     INLINE $203C,$0030,midiToolNum,$A800;
  203. PROCEDURE MIDIFlush(refnum: INTEGER);
  204.     INLINE $203C,$0034,midiToolNum,$A800;
  205. FUNCTION MIDIGetReadHook(refnum: INTEGER): ProcPtr;
  206.     INLINE $203C,$0038,midiToolNum,$A800;
  207. PROCEDURE MIDISetReadHook(refnum: INTEGER;hook: ProcPtr);
  208.     INLINE $203C,$003C,midiToolNum,$A800;
  209. PROCEDURE MIDIGetPortName(clientID: OSType;portID: OSType;VAR name: Str255);
  210.     INLINE $203C,$0040,midiToolNum,$A800;
  211. PROCEDURE MIDISetPortName(clientID: OSType;portID: OSType;name: Str255);
  212.     INLINE $203C,$0044,midiToolNum,$A800;
  213. PROCEDURE MIDIWakeUp(refnum: INTEGER;time: LONGINT;period: LONGINT;timeProc: ProcPtr);
  214.     INLINE $203C,$0048,midiToolNum,$A800;
  215. PROCEDURE MIDIRemovePort(refnum: INTEGER);
  216.     INLINE $203C,$004C,midiToolNum,$A800;
  217. FUNCTION MIDIGetSync(refnum: INTEGER): INTEGER;
  218.     INLINE $203C,$0050,midiToolNum,$A800;
  219. PROCEDURE MIDISetSync(refnum: INTEGER;sync: INTEGER);
  220.     INLINE $203C,$0054,midiToolNum,$A800;
  221. FUNCTION MIDIGetCurTime(refnum: INTEGER): LONGINT;
  222.     INLINE $203C,$0058,midiToolNum,$A800;
  223. PROCEDURE MIDISetCurTime(refnum: INTEGER;time: LONGINT);
  224.     INLINE $203C,$005C,midiToolNum,$A800;
  225. PROCEDURE MIDIStartTime(refnum: INTEGER);
  226.     INLINE $203C,$0060,midiToolNum,$A800;
  227. PROCEDURE MIDIStopTime(refnum: INTEGER);
  228.     INLINE $203C,$0064,midiToolNum,$A800;
  229. PROCEDURE MIDIPoll(refnum: INTEGER;offsetTime: LONGINT);
  230.     INLINE $203C,$0068,midiToolNum,$A800;
  231. FUNCTION MIDIWritePacket(refnum: INTEGER;packet: MIDIPacketPtr): OSErr;
  232.     INLINE $203C,$006C,midiToolNum,$A800;
  233. FUNCTION MIDIWorldChanged(clientID: OSType): BOOLEAN;
  234.     INLINE $203C,$0070,midiToolNum,$A800;
  235. FUNCTION MIDIGetOffsetTime(refnum: INTEGER): LONGINT;
  236.     INLINE $203C,$0074,midiToolNum,$A800;
  237. PROCEDURE MIDISetOffsetTime(refnum: INTEGER;offsetTime: LONGINT);
  238.     INLINE $203C,$0078,midiToolNum,$A800;
  239. FUNCTION MIDIConvertTime(srcFormat: INTEGER;dstFormat: INTEGER;time: LONGINT): LONGINT;
  240.     INLINE $203C,$007C,midiToolNum,$A800;
  241. FUNCTION MIDIGetRefCon(refnum: INTEGER): LONGINT;
  242.     INLINE $203C,$0080,midiToolNum,$A800;
  243. PROCEDURE MIDISetRefCon(refnum: INTEGER;refCon: LONGINT);
  244.     INLINE $203C,$0084,midiToolNum,$A800;
  245. FUNCTION MIDIGetClRefCon(clientID: OSType): LONGINT;
  246.     INLINE $203C,$0088,midiToolNum,$A800;
  247. PROCEDURE MIDISetClRefCon(clientID: OSType;refCon: LONGINT);
  248.     INLINE $203C,$008C,midiToolNum,$A800;
  249. FUNCTION MIDIGetTCFormat(refnum: INTEGER): INTEGER;
  250.     INLINE $203C,$0090,midiToolNum,$A800;
  251. PROCEDURE MIDISetTCFormat(refnum: INTEGER;format: INTEGER);
  252.     INLINE $203C,$0094,midiToolNum,$A800;
  253. PROCEDURE MIDISetRunRate(refnum: INTEGER;rate: INTEGER;time: LONGINT);
  254.     INLINE $203C,$0098,midiToolNum,$A800;
  255. FUNCTION MIDIGetClientIcon(clientID: OSType): Handle;
  256.     INLINE $203C,$009C,midiToolNum,$A800;
  257.  
  258.  
  259. {$ENDC}    { UsingMIDI }
  260.  
  261. {$IFC NOT UsingIncludes}
  262.     END.
  263. {$ENDC}
  264.  
  265.